﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Acoris.Parser
{
    /// <summary>
    /// 表示一个状态帧
    /// </summary>
    public sealed class StateFrame<TokenType>
    {
        readonly DFAState<TokenType> _state;
        readonly TokenBase<TokenType> _last;
        readonly TokenBase<TokenType> _now;
        readonly DFAState<TokenType> _lastState;

        public StateFrame(
            DFAState<TokenType> lastState,DFAState<TokenType> currentState,
            TokenBase<TokenType> last,TokenBase<TokenType> now)
        {
            _state = currentState ?? throw new NullReferenceException();
            _lastState = lastState;
            _last = last;
            _now = now;
        }

        /// <summary>
        /// 表示状态帧当前的状态
        /// </summary>
        public DFAState<TokenType> CurrentState {
            get {
                return _state;
            }
        }

        /// <summary>
        /// 表示状态帧之前的状态
        /// </summary>
        public DFAState<TokenType> LastState {
            get {
                return _lastState;
            }
        }

        /// <summary>
        /// 表示状态帧上一个传递的记号
        /// </summary>
        public TokenBase<TokenType> LastToken {
            get {
                return _last;
            }
        }

        /// <summary>
        /// 表示状态帧当前传递的记号
        /// </summary>
        public TokenBase<TokenType> Token {
            get {
                return _now;
            }
        }
    }
}
